﻿using System.Net.Sockets;
using JetBlack.IO;

namespace JetBlack.Net.Sockets
{
    internal class BlockingReader
    {
        public readonly Socket Socket;

        public BlockingReader(Socket socket)
        {
            Socket = socket;
        }

        public byte[] Read()
        {
            byte[] len = new byte[4];
            Socket.Receive(len);
            byte[] buffer = new byte[NetworkBitConverter.ToInt32(len, 0)];
            Socket.Receive(buffer);
            return buffer;
        }
    }
}
